import java.util.ArrayList;


public class State implements java.io.Serializable
{
	private static final long serialVersionUID = -8476976942134313759L;
	private boolean[] mask;
	private char c;
	private ArrayList<State> children;
	
	public State(boolean[] mask, char c)
	{
		this.mask = mask;
		this.c = c;
		children = new ArrayList<State>();
	}
	
	public State getNextState(char c)
	{
		for(State s : children)
		{
			if(s.getChar() == c)
				return s;
		}
		
		return null;
	}
	
	public ArrayList<State> getChildren()
	{
		return children;
	}
	
	public void addChild(State s)
	{
		if(!children.contains(s))
			children.add(s);
	}
	
	public boolean[] getMask()
	{
		return mask;
	}
	
	public char getChar()
	{
		return c;
	}
	
	public void setMask(boolean[] mask)
	{
		this.mask = mask;
	}
	
	public String toString()
	{
		String s;
		if(c != '\0')
			s = "Char: " + c + "; Mask: ";
		else
			s = "Char: " + "\\0" + "; Mask: ";
			
		for(int i = 0; i < mask.length; i++)
			s += mask[i] ? '1' : '0';
		
		return s;
	}
}
